<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>


<@body>
<script src="/misc/app/js/region_list.js"></script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${regionList.resultTotal} 条记录</span>
        <form class="form-inline" action="/region">
            <div class="input-group">
                <div class="input-group-addon">父级id</div>
                <input type="text" class="form-control" style="width: 260px" name="parentId" value="${parentId!}" placeholder="输入父级id"/>
            </div>

            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
           <!-- <button type="button" class="btn btn-default" name="btn_new_region" data-toggle="modal" data-target="#md_new_region"><i class="fa fa-plus"></i> 新增地区</button> -->
        </form>
        <form class="form-inline hide">
            <input class="form-control"/>
            <input type="email" class="form-control"/>
            <button type="submit" class="btn btn-default">Send invitation</button>
        </form>
    </div>

    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>名称</th>
                <th>级别</th>
                <th>父级id</th>
                <th>父级名称</th>
           
                <th>操作</th>
            </tr>
            <#if (regionList.result?size > 0)>
                <#list regionList.result as item>
                    <tr>
                        <td>${item.id}</td>
                        <td>${item.name}</td>
                        <td>${item.regionType}</td>
                        <td>${item.parentId}</td>
                        <td>${item.parentName!}</td>
                     
                        <td>
                        	<!-- 
                            <button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#md_edit_region" data-region-id="${item.id}">编辑</button>
                            <button type="button" class="btn btn-default btn-xs" name="btn_delete_region" data-region-id="${item.id}">删除</button>
                            -->
                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="6"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/region?parentId=${parentId!}&page=$page",regionList.page,regionList.pageTotal/>
    </div>
</div>

<!-- new -->
<div class="modal" id="md_new_region" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-plus"></i> 新增地区</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_new_region">
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 父级id</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="父级id" name="parentId"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 地区名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="地区名称" name="name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 地区级别</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="地区级别" name="regionType"/>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_new_region">保存</button>
            </div>
        </div>
    </div>
</div>


<!-- edit  -->
<div class="modal" id="md_edit_region" tabindex="-1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"><i class="fa fa-pencil-square-o"></i> 编辑地区</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" name="form_edit_region">
                    <input type="hidden" name="id"/>

                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 父级id</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="父级id" name="parentId"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 地区名称</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="地区名称" name="name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label"><strong class="text-red bold">*</strong> 地区级别</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" placeholder="地区级别" name="regionType"/>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" name="btn_save_edit_region">保存</button>
            </div>
        </div>
    </div>
</div>

</@layout_default>